package com.jp.vn.main;

import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class TimKiemActivity extends Activity {
	
	EditText tfSearch;
	ImageView btnMenu;
	LinearLayout menu_popup;
	int height = 0;
	int width = 0;
	int space = 0;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tim_kiem);
		
		tfSearch = (EditText) findViewById(R.id.tfSearch);
		btnMenu = (ImageView) findViewById(R.id.btnMenu);

		menu_popup = (LinearLayout)findViewById(R.id.menu_popup);
		
		Typeface type = Typeface.createFromAsset(getAssets(),"fonts/tekton.ttf");
		tfSearch.setTypeface(type, Typeface.BOLD_ITALIC);
		
		btnMenu.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				PopupMenu menu = new PopupMenu(v, height, width);
				menu.showPopup(space+5);
			}
		});
	}
	
	@Override
	public void onWindowFocusChanged(boolean hasFocus) {
		super.onWindowFocusChanged(hasFocus);
		
		width = menu_popup.getWidth();
		menu_popup.setVisibility(View.GONE);
		height = (int) getResources().getDimension(R.dimen.menupopup_height);
		space = (int) getResources().getDimension(R.dimen.menu_height);
		
		Log.w("width===========================", width+"");
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		finish();
	}
	
	@Override
	public void onBackPressed() {
		super.onBackPressed();
		overridePendingTransition(R.anim.left_in, R.anim.right_out);
		finish();
	}
}
